package com.hashimoto.edge.test.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hashimoto.core.remote.client.edge.EdgeClient;
import com.hashimoto.core.remote.exchange.CallMessage;

@Service
public class QueryService {
	
	@Autowired
	public EdgeClient edgeClient;
	
	/**
	 * 调用下发处理业务
	 * @param message
	 */
	public void call(CallMessage message) {
		String queryInterface = message.getInterfaceName();
		switch(queryInterface) {
		case "queryQrCode":
			ResultDto<String> resultDto = new ResultDto<>();
			resultDto.setCode(0);
			resultDto.setData(message.fromString());
			resultDto.setMessage("success");
			edgeClient.send(message.getInterfaceName(), message.getMsgId(), 0, message.getCallId(), resultDto);
			break;
		default:
			resultDto = new ResultDto<>();
			resultDto.setCode(-100);
			resultDto.setData(message.toString());
			resultDto.setMessage("false");
			edgeClient.send(message.getInterfaceName(), message.getMsgId(), -100, message.getCallId(), resultDto);
			break;
		}
	}

}
